using Furion.DatabaseAccessor;

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

using Tool;

namespace Abc.Core.Entities
{
    /// <summary>
    /// 数据配置
    /// </summary>
    [Comment("数据配置")]
    // [Table("数据配置")]
    public class DataConfig : FullEntity
, IEntityTypeBuilder<DataConfig>
, IEntitySeedData<DataConfig>
, IExtension
    {
        /// <summary>
        /// 唯一标识Key
        /// </summary>
        [Comment("唯一标识Key")]
        public string Key { get; set; }

        /// <summary>
        /// 父Key
        /// </summary>
        [Comment("PKey")]
        public string PKey { get; set; }

        ///// <summary>
        ///// 关键词
        ///// </summary>
        //[Comment("关键词")]
        //public string Key { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [MaxLength(100)]
        [Comment("名称")]
        public string Name { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        [Comment("值")]
        public string Value { get; set; }

        /// <summary>
        /// 值2
        /// </summary>
        [Comment("值扩展")]
        public string Value2 { get; set; }

        /// <summary>
        /// 值3
        /// </summary>
        [Comment("值3")]
        public string Value3 { get; set; }

        /// <summary>
        /// 值4
        /// </summary>
        [Comment("值4")]
        public string Value4 { get; set; }

        /// <summary>
        /// 值5
        /// </summary>
        [Comment("值5")]
        public string Value5 { get; set; }

        /// <summary>
        /// 分组
        /// </summary>
        [MaxLength(100)]
        [Comment("分组")]
        public string GroupName { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        [Comment("排序")]
        public int Sort { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        [Comment("是否启用")]
        public bool IsEnable { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Comment("备注")]
        public string Remark { get; set; }

        /// <summary>
        /// 扩展json数据字段
        /// <c><Dictionary<string,string></c>
        /// </summary>
        [Comment("扩展参数")]
        public string ExtensionData { get; set; }

        public void Configure(EntityTypeBuilder<DataConfig> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            //entityBuilder
            //    .HasMany(x => x.Childrens)
            //    .WithOne(x => x.Parent)
            //    .HasForeignKey(x => x.PId)
            //    .OnDelete(DeleteBehavior.ClientSetNull); // 必须设置这一行
        }

        public IEnumerable<DataConfig> HasData(DbContext dbContext, Type dbContextLocator)
        {
            var dataconfigs = new List<DataConfig>
            {
                new DataConfig { Id = 1,Key="SystemSetting",PKey="",Name="系统设置",Value="" },
                new DataConfig { Id = 2,Key="EmailSetting",PKey="",Name="邮件设置",Value="" },
                #region
                //new DataConfig { Id = 1,PId=0,Key = "Syssetting",Name="",Value="" },
                //new DataConfig { Id = 2,PId=0,Key="Rotation", Name = "轮播图" ,Value=""},

                //new DataConfig { Id = 21,PId=1,Key="WebName", Name = "网站名称" ,Value="农业对外合作专家信息库"},
                //new DataConfig { Id = 22,PId=1,Key="WebDomain", Name = "网站域名" ,Value=""},
                //new DataConfig { Id = 23,PId=1,Key="DatabaseBackupPath", Name = "数据库备份路径" ,Value="dbblack"},
                //new DataConfig { Id = 24,PId=1,Key="DatabaseBackupSwitch", Name = "数据库备份开关" ,Value="false"},
                //new DataConfig { Id = 25,PId=1,Key="DatabaseBackupTime", Name = "数据库备份时间" ,Value="02:00"},
                //new DataConfig { Id = 26,PId=1,Key="WebBeianNo", Name = "网站备案号" ,Value=""},
                //new DataConfig { Id = 27,PId=1,Key="ContactUs", Name = "联系我们" ,Value=""},
                //new DataConfig { Id = 28,PId=1,Key="AboutUs", Name = "关于我们" ,Value=""},
                //new DataConfig { Id = 29,PId=1,Key="HelpCenter", Name = "帮助中心" ,Value=""},
                //new DataConfig { Id = 30,PId=1,Key="MetaKeywords", Name = "META关键词" ,Value="农业,专家库,对外合作,专家信息库"},
                //new DataConfig { Id = 31,PId=1,Key="MetaDescribe", Name = "META描述" ,Value="农业对外合作专家信息库"},
                //new DataConfig { Id = 32,PId=1,Key="CopyrightInformation", Name = "版权信息" ,Value="©2012-2021 农业对外合作专家信息库 版权所有"},
                //new DataConfig { Id = 33,PId=1,Key="EmailSmtpHost", Name = "SMTP服务器",Value="smtp.qq.com" },
                //new DataConfig { Id = 34,PId=1,Key="EmailSmtpPort", Name = "SMTP端口" ,Value="465"},
                //new DataConfig { Id = 35,PId=1,Key="EmailUser", Name = "发送邮件账户" ,Value="190760753@qq.com"},
                //new DataConfig { Id = 36,PId=1,Key="EmailPassword", Name = "发送邮件账户密码" ,Value="zjk123654"},
                //new DataConfig { Id = 37,PId=1,Key="EmailFrom", Name = "发送邮件来源" ,Value="190760753@qq.com"},
                //new DataConfig { Id = 38,PId=1,Key="EmailIsHtml", Name = "是否包含Html代码" ,Value="true"},
                //new DataConfig { Id = 39,PId=1,Key="EmailDisplayName", Name = "发送者显示名" ,Value="农业对外合作专家信息库"},
                //new DataConfig { Id = 40,PId=1,Key="EmailEnableSsl", Name = "是否启用SSL加密" ,Value="false"},
                //new DataConfig { Id = 41,PId=1,Key="WxQrcode", Name = "微信公众号二维码" ,Value=""},
                //new DataConfig { Id = 42,PId=1,Key="ContactTel", Name = "联系电话" ,Value=""},
                //new DataConfig { Id = 43,PId=1,Key="ContactEmail", Name = "联系邮箱" ,Value=""},
                #endregion

                // new DataConfig{ Id = 100,PId=7,Key="教育", Name = "教育" ,Value=""},
            };

            return dataconfigs;
        }
    }
}